From 8c65284b44337c6cfc003cedc8996e241ac678bd Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 17 Dec 2015 14:14:40 -0700 Subject: [PATCH] Pass link search path to doctests even if build script gave no links It is entirely possible for a crate to have a build script that is simply the equivalent to ```rustc fn main() { println!("cargo:rustc-link-search=native=/some/path"); } ``` Without actually giving anything to link (for example, because the code contains `#[link(name="foo")]`. In this case, we aren't actually passing `-L` through when running doctests, even though they're passed when compiling the main crate. Fixes #1592 --- src/cargo/ops/cargo_rustc/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index d62f8cbf1..434faa20b 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -162,7 +162,9 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a PackagesToBuild<'a>, let any_dylib = output.library_links.iter().any(|l| { !l.starts_with("static=") && !l.starts_with("framework=") }); - if !any_dylib { continue } + if !any_dylib && !output.library_links.is_empty() { + continue + } for dir in output.library_paths.iter() { cx.compilation.native_dirs.insert(pkg.clone(), dir.clone()); } -- 2.30.2